<%@page import="java.util.List"%>
<%@page import="team.*"%>
<%@page contentType="text/html" pageEncoding="UTF-8"%>
<%@page errorPage="error.jsp" %>
<%@ include file="header.jspf" %>
<%@ include file="team_header.jspf" %>	


<section class="middle">
    
    
    <div class="teaser">
        <div class="gray_teaser star_teaser">

            <p>Teams</p>

            <br class="clear">

            <div class="teaser-block-left f-left star_teaser">

                <table class="teaser-table" cellspacing="0" cellpadding="0" id="table">

                    <thead>                                                                    
                    <th class="nosort"></th>            
                    <%
                        if (request.getParameter("sport") != null) {
                            if (request.getParameter("sport").equals("football")) {
                                session.setAttribute("sport", Integer.valueOf(1));
                            }
                            if (request.getParameter("sport").equals("basketball")) {
                                session.setAttribute("sport", Integer.valueOf(2));
                            }
                            if (request.getParameter("sport").equals("hockey")) {
                                session.setAttribute("sport", Integer.valueOf(3));
                            }
                        }
                        Team team = TeamFabric.getInstance(((Integer) session.getAttribute("sport")).intValue());
                    %>
                    <th>#</th>
                    <th>name</th>
                    <%
                        if (team != null) {
                            List attrs = team.getAttrsNames();
                            for (int i = 0; i < attrs.size(); i++) {
                                if (!attrs.get(i).equals("name") && !attrs.get(i).equals("id") && !attrs.get(i).equals("sportId")) {

                    %>
                    <th><%=attrs.get(i)%> </th>
                    <%
                                }
                            }
                        }
                    %>                                                                       
                    </thead>
                    <tbody>
                        <jsp:include page="sport?page=teams" />                                                                           
                    </tbody>
                </table>
                <script type="text/javascript">
                    var sorter = new TINY.table.sorter("sorter");
                    sorter.head = "head";
                    sorter.asc = "asc";
                    sorter.desc = "desc";
                    sorter.even = "evenrow";
                    sorter.odd = "oddrow";
                    sorter.evensel = "evenselected";
                    sorter.oddsel = "oddselected";
                    sorter.paginate = true;
                    sorter.currentid = "currentpage";
                    sorter.limitid = "pagelimit";
                    sorter.init("table",1);
                </script>
            </div>

            <div class="border_teaser"></div>

        </div>
        <br class="clear">

        <button class=sportbutton onclick="window.location = 'add_team.jsp';">add</button>
        &nbsp;&nbsp;
        <button class=sportbutton onclick="remove('teams')">remove</button>
    </div>

    <br class="clear">
</section>

<%@ include file="footer.jspf" %>                                